package com.social.serviceImpl;

import com.social.dao.OrganizationMapper;
import com.social.pojo.Organization;
import com.social.service.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrganizationServiceImpl implements OrganizationService {
    @Autowired
    private OrganizationMapper organizationMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        int status = organizationMapper.deleteByPrimaryKey(id);
        return status;
    }

    @Override
    public int insert(Organization record) {
        int status = organizationMapper.insert(record);
        return status;
    }

    @Override
    public int insertSelective(Organization record) {
        int status = organizationMapper.insertSelective(record);
        return status;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public Organization selectByPrimaryKey(Integer id) {
        Organization organizations = organizationMapper.selectByPrimaryKey(id);
        return organizations;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<Organization> selectAll(Integer page, Integer pageNum) {
        List<Organization> organizations = organizationMapper.selectAll(page, pageNum);
        return organizations;
    }
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public Organization selectByUsername(String departmentName) {
        Organization organization = organizationMapper.selectByUsername(departmentName);
        return organization;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public int selectAllCount() {
        int status = organizationMapper.selectAllCount();
        return status;
    }

    @Override
    public int updateByPrimaryKeySelective(Organization record) {
        int status = organizationMapper.updateByPrimaryKeySelective(record);
        return status;
    }

    @Override
    public int updateByPrimaryKey(Organization record) {
        int status = organizationMapper.updateByPrimaryKey(record);
        return status;
    }
}
